<template>
    <div class="text-center timeline-layout">
        <div class="step-icon-box main-step nor-step" :class="{'doing':step1==1,'done':step1==2}">
            <div class="icon">
                <i class="fa fa-check"></i>
            </div>
            <div class="text">受理</div>
        </div>
        <div class="loading-img" :class="{'doing':step1==1,'done':step1==2}">
            <span></span><span></span><span></span>
        </div>

        <div class="step-icon-box main-step nor-step" :class="{'doing':step2==1,'done':step2==2}">
            <div class="icon">
                <i class="fa fa-comments-o"></i>
            </div>
            <div class="text">答复</div>
        </div>
        <div class="loading-img" :class="{'doing':step2==1,'done':step2==2}">
            <span></span>
        </div>


        <div class="step-icon-box inside-step nor-step" :class="{'doing':step3==1,'done':step3==2}">
            <div class="icon">
                <i class="fa fa-code" aria-hidden="true"></i>
            </div>
            <div class="text">研发</div>
        </div>
        <div class="loading-img" :class="{'doing':step3==1,'done':step3==2}">
            <span></span>
        </div>


        <div class="step-icon-box inside-step nor-step" :class="{'doing':step4==1,'done':step4==2}">
            <div class="icon">
                <i class="fa fa-gears" aria-hidden="true"></i>
            </div>
            <div class="text">测试</div>
        </div>
        <div class="loading-img" :class="{'doing':step4==1,'done':step4==2}">
            <span></span>
        </div>


        <div class="step-icon-box inside-step nor-step" :class="{'doing':step5==1,'done':step5==2}">
            <div class="icon">
                <i class="fa fa-sticky-note-o" aria-hidden="true"></i>
            </div>
            <div class="text">评审</div>
        </div>
        <div class="loading-img" :class="{'doing':step5==1,'done':step5==2}">
            <span></span>
        </div>


        <div class="step-icon-box main-step nor-step" :class="{'doing':step6==1||(step6==2&&(step7==0||step7==1)),'done':step6==2}">
            <div class="icon">
                <i class="fa fa-cube" aria-hidden="true"></i>
            </div>
            <div class="text">交付</div>
        </div>
        <div class="loading-img" :class="{'doing':step1==6,'done':step6==2}">
            <span></span>
            <span></span>
            <span></span>
        </div>


        <div class="step-icon-box main-step last-step" :class="{'doing':step7==1,'done':step7==2}">
            <div class="icon">
                <i class="fa fa-suitcase" aria-hidden="true"></i>
            </div>
            <div class="text">验收</div>
        </div>
    </div>
</template>
<script>
export default {
    name:'FbTimeline',
    data(){
        return {
            step1:0,
            step2:0,
            step3:0,
            step4:0,
            step5:0,
            step6:0,
            step7:0
        }
    },
    props:{
        feedbackStatus:{
            type:Array,
            default(){
                return [
                    {type:1,status:0},
                    {type:2,status:0},
                    {type:3,status:0},
                    {type:4,status:0},
                    {type:5,status:0},
                    {type:6,status:0},
                    {type:7,status:0}
                ]
            }
        }
    },
    watch:{
        feedbackStatus:{
            deep: true,
            handler(v,ov){
                this.setData(v);
            }
        }
    },
    methods:{
        setData(v){
            var self = this;
            v.map((v,i)=>{
                var t = v.type;
                switch(t){
                    case 1:
                    self.step1 = v.status;
                    break;
                    case 2:
                    self.step2 = v.status;
                    break;
                    case 3:
                    self.step6 = v.status;
                    break;
                    case 4:
                    self.step7 = v.status;
                    break;
                    case 5:
                    self.step3 = v.status;
                    break;
                    case 6:
                    self.step4 = v.status;
                    break;
                    case 7:
                    self.step5 = v.status;
                    break;
                }
            });
        }
    },
    mounted(){
        var self = this;
        self.setData(self.feedbackStatus);
    }
}
</script>
<style scoped>
.timeline-layout{
    padding:80px 0 60px;
}

.step-icon-box{
    display: inline-block;
    text-align: center;
    box-sizing: border-box;
    padding: 10px;
    vertical-align:top;
    position: relative;
    width: 60px;
}
.step-icon-box .icon{height: 60px;line-height: 60px;}
.step-icon-box .icon .fa{background-color: #ecf2f7;color: #b8c6d6;}
.step-icon-box.main-step .icon .fa{
    width: 40px;
    height: 40px;
    line-height: 40px;
    border-radius: 50%;
    font-size: 24px;
    transition: all 0.3s;
}
.step-icon-box.inside-step .icon .fa{
    width: 30px;
    height: 30px;
    line-height: 30px;
    border-radius: 20%;
    font-size: 16px;
    transition: all 0.3s;
}
.step-icon-box .text{color:#b8c6d6;}
.loading-img{
    display: inline-block;
    margin: 0px;
    height: 80px;
    box-sizing: border-box;
    vertical-align:top;
    padding-top: 25px;
}
.loading-img>span{
    vertical-align: middle;
    display: inline-block;
    background-color: #ecf2f7;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin: 5px;
}

.step-icon-box.nor-step.doing .text{color:#333;}
.step-icon-box.nor-step.doing .fa{color:#5184d2;}
.step-icon-box.nor-step.doing:after,.step-icon-box.last-step.done:after{
    content: "当前进度";
    position: absolute;
    font-size: 12px;
    border-radius: .4rem;
    padding: 12.8px;
    padding: .8rem;
    color: #b8c6d6;
    line-height: 20px;
    line-height: 1.25rem;
    text-align: left;
    z-index: 1;
    pointer-events: none;
    display: block;
    bottom: 95px;
    width: 100px;
    left: -12px;
    text-align: center;
    white-space: pre;
    width: 80px;
}
.step-icon-box.nor-step.doing:before,.step-icon-box.last-step.done:before{
    content: " ";
    height: 0;
    width: 0;
    display: block;
    border-top: 5px solid #b8c6d6;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    left: 24px;
    bottom: 90px;
    position: absolute;
}
.loading-img.doing>span{
    opacity: 0.2;
    animation-name:p1;
    animation-duration:1s;
    animation-timing-function:ease-in-out;
    animation-iteration-count:infinite;
    animation-direction:alternate;
    background-color: #b8c6d6;
}
.loading-img.doing>span:nth-child(1){
    animation-delay:0s;
}
.loading-img.doing>span:nth-child(2){
    animation-delay:0.5s;
}
.loading-img.doing>span:nth-child(3){
    animation-delay:1s;
}

.step-icon-box.done.last-step:after{
    content:'已完成'
}
.loading-img.done>span{
    background-color: #5184d2;
}



.step-icon-box.done .icon .fa{background-color: #5184d2;color:#fff;}
.step-icon-box.done .text{color:#5184d2;}
.loading-img.done>span{background-color: #5184d2;}


@keyframes p1{
  0% {opacity:0.2;}
  100% {opacity:1;}
}
</style>